<extend name="./base" />
<block name="pageContent">
    <link rel="stylesheet" href="{$Think.config.DOMAIN_URL}/Public/AdminTpl/css/s-settle.css">
    <div class="main-content">
        <!-- 头部面包屑导航条 -->
        <div class="breadcrumbs" id="breadcrumbs">
            <!--导航路径列表-->
            <ul class="breadcrumb no-margin-left">
                <li>
                    <a>管理后台</a>
                </li>
                <li class="action">
                    股票管理
                </li>
            </ul>
        </div>
        <!--页面容器-->
        <div class="page-content">
            <div class="nav-tab" style="position: relative">
                <ul class="nav-tab-title ">
                    <li class="nav-this">交易设置</li>
                </ul>
            </div>
            <div class="row">
                <div class="col-xs-12">
                    <div class="row">
                        <form class="jsform">
                            <div class="s_form-textarea">
                                <span>涨跌幅</span>
                                <input type="number" id="rang_space" value="{$tsRes.rang_space}" class="s_form-width" datatype="*" placeholder="请输入涨跌幅"/>
                                <em class="type-add-p color-gray9" style="margin-left: 20px">%</em>
                            </div>
                            <div class="s_form-textarea">
                                <span>手续费比例</span>
                                <input type="number" id="trade_fee" value="{$tsRes.trade_fee}" class="s_form-width" datatype="*" placeholder="请输入手续费比例"/>
                                <em class="type-add-p color-gray9" style="margin-left: 20px">‰</em>
                            </div>
                            <div class="s_form-textarea">
                                <span>开盘时间</span>
                                <input type="text" id="stime" value="{$tsRes.stime}" class="s_form-width" datatype="*" placeholder="请输入开盘时间"/>
                            </div>
                            <div class="s_form-textarea">
                                <span>收盘时间</span>
                                <input type="text" id="etime" value="{$tsRes.etime}" class="s_form-width" datatype="*" placeholder="请输入收盘时间"/>
                            </div>
                            <div class="s_form-textarea">
                                <span>自动开盘收盘</span>
                                <input class="checkbox col-sm-1" id="auto_open_close" <eq name="tsRes.auto_open_close" value="1">checked</eq> type="checkbox" style="width: 2%">
                            </div>
                            <div class="s_form-textarea">
                                <span>闭市撤销委托</span>
                                <input class="checkbox col-sm-1" id="auto_back_close" <eq name="tsRes.auto_back_close" value="1">checked</eq> type="checkbox" style="width: 2%">
                            </div>
                            <div class="s_form-textarea">
                                <span>开市日期</span>
                                <input class="checkbox col-sm-1 week_list" type="checkbox" value="1" <assign name="week" value="1" /><in name="week" value="$tsRes[week_list]">checked</in> style="width: 2%"><em class="type-add-p color-gray9" style="margin-left: 0px">周一</em>
                                &nbsp;&nbsp;&nbsp;&nbsp;<input class="checkbox col-sm-1 week_list" type="checkbox" value="2" <assign name="week" value="2" /><in name="week" value="$tsRes[week_list]">checked</in> style="width: 2%"><em class="type-add-p color-gray9" style="margin-left: 0px">周二</em>
                                &nbsp;&nbsp;&nbsp;&nbsp;<input class="checkbox col-sm-1 week_list" type="checkbox" value="3" <assign name="week" value="3" /><in name="week" value="$tsRes[week_list]">checked</in> style="width: 2%"><em class="type-add-p color-gray9" style="margin-left: 0px">周三</em>
                                &nbsp;&nbsp;&nbsp;&nbsp;<input class="checkbox col-sm-1 week_list" type="checkbox" value="4" <assign name="week" value="4" /><in name="week" value="$tsRes[week_list]">checked</in> style="width: 2%"><em class="type-add-p color-gray9" style="margin-left: 0px">周四</em>
                                &nbsp;&nbsp;&nbsp;&nbsp;<input class="checkbox col-sm-1 week_list" type="checkbox" value="5" <assign name="week" value="5" /><in name="week" value="$tsRes[week_list]">checked</in> style="width: 2%"><em class="type-add-p color-gray9" style="margin-left: 0px">周五</em>
                                &nbsp;&nbsp;&nbsp;&nbsp;<input class="checkbox col-sm-1 week_list" type="checkbox" value="6" <assign name="week" value="6" /><in name="week" value="$tsRes[week_list]">checked</in> style="width: 2%"><em class="type-add-p color-gray9" style="margin-left: 0px">周六</em>
                                &nbsp;&nbsp;&nbsp;&nbsp;<input class="checkbox col-sm-1 week_list" type="checkbox" value="7" <assign name="week" value="7" /><in name="week" value="$tsRes[week_list]">checked</in> style="width: 2%"><em class="type-add-p color-gray9" style="margin-left: 0px">周日</em>
                            </div>
                            <div style="margin: 50px 80px;">
                                <button type="button" onclick="stockSet()"  class="btn " style="width: 100px; border-radius: 2rem; background: #0451d7!important;border:1px solid #0451d7;margin-left: 20px;">确认</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        laydate.render({
            elem: '#stime'
            ,type: 'time'
        });
        laydate.render({
            elem: '#etime'
            ,type: 'time'
        });
        //交易设置
        function stockSet() {
            var rang_space = $('#rang_space').val();
            var trade_fee = $('#trade_fee').val();
            var stime = $('#stime').val();
            var etime = $('#etime').val();
            var auto_open_close = $('#auto_open_close').is(':checked') ? 1 : 0;
            var auto_back_close = $('#auto_back_close').is(':checked') ? 1 : 0;
            var week_list = [];
            $('.week_list').each(function () {
                if($(this).is(':checked')){
                    week_list.push($(this).val());
                }
            });
            if(!rang_space || !trade_fee || !stime || !etime || week_list.length==0){
                return false;
            }

            $.ajax({
                type:"post",
                dataType:"json",
                url:"/stock/set",
                data:{
                    rang_space: rang_space,
                    trade_fee: trade_fee,
                    stime: stime,
                    etime: etime,
                    auto_open_close: auto_open_close,
                    auto_back_close: auto_back_close,
                    week_list: week_list
                },
                success:function(data){
                    if(data.code == 0){
                        layer.msg('操作成功', {icon: 6,time: 1500});
                    }else{
                        layer.msg(data.msg, {icon: 5,time: 1500});
                    }
                }
            });
        }
    </script>
</block>